<?php

class CheckController extends Controller
{
	public function actionIndex()
	{
		
	$preSelectedJenis = array();
	$preSelectedWaktu = array();
	$preSelectedHarga = array();
	//if(isset($_POST['checkboxlistsubmit']))
	//{   
		if(isset($_POST['myCheckBoxList']['jenis']) || isset($_POST['myCheckBoxList']['waktu']) ||  isset($_POST['myCheckBoxList']['harga']))
		{
			$message = "You selected: ";  
			$loopCount = 0;
			$preSelectedJenis = array();
			$preSelectedWaktu = array();
			$preSelectedHarga = array();
			
			foreach($_POST['myCheckBoxList']['jenis'] as $selectedJenis)
			{
			     $message .= strval($selectedJenis) . " ";
			     if(++$loopCount < count($_POST['myCheckBoxList']['jenis']))   
			          $message .=  " & ";
			     $preSelectedJenis[] = $selectedJenis;
            }
			
			foreach($_POST['myCheckBoxList']['waktu'] as $selectedWaktu)
			{
			     $message .= strval($selectedWaktu) . " ";
			     if(++$loopCount < count($_POST['myCheckBoxList']['waktu']))   
			          $message .=  " & ";
			     $preSelectedWaktu[] = $selectedWaktu;
            }
			
			foreach($_POST['myCheckBoxList']['harga'] as $selectedHarga)
			{
			     $message .= strval($selectedHarga) . " ";
			     if(++$loopCount < count($_POST['myCheckBoxList']['harga']))   
			          $message .=  " & ";
			     $preSelectedHarga[] = $selectedHarga;
            }
		}
		else 
		     $message = "Nothing Selected.";
		echo $message;
		//Yii::app()->user->setFlash('selectedValues',$message); 
	//} 
	
	
	$this->render('index', array('jenisPilih'=>$preSelectedJenis, 
								 'waktuPilih'=>$preSelectedWaktu, 
								 'hargaPilih'=>$preSelectedHarga)); 
	}
public function actionCheckboxlist() 
{                                    
}
	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			'inlineFilterName',
			array(
				'class'=>'path.to.FilterClass',
				'propertyName'=>'propertyValue',
			),
		);
	}

	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/
}